import { Component, Vue, Prop, Watch } from 'vue-property-decorator';

@Component({
  components: {
  }
})
export default class ListLayer extends Vue {
  @Prop({
    required: false,
    default: 'dom_map',
  }) domID!: any;

  treeData = [
    {
      title: '行政执法',
      key: '0',
      children: [
        {
          title: '行政处罚案件',
          key: '0-1'
        },
        {
          title: '行政检查案件',
          key: '0-2',
          children: [
            { title: '0-1-0', key: '0-1-0' },
            { title: '0-1-1', key: '0-1-1' },
            { title: '0-1-2', key: '0-1-2' },
          ],
        },
        {
          title: '法人',
          key: '0-3',
        },
      ],
    },
    {
      title: '国民经济',
      key: '1',
      children: [
        { title: '一套表企业', key: '1-0' },
        { title: '非一套表企业', key: '1-1' },
      ],
    },
    {
      title: '城市管理',
      key: '2',
      children: [
        { title: '部件', key: '2-0' },
        { title: '事件', key: '2-1' },
      ],
    }
  ];
  expandedKeys = ['0','1','2'];
  autoExpandParent =  true;
  checkedKeys = ['0-3'];
  selectedKeys = [];

  // 监听事件 immediate: true 初始化加载一次  deep: true 对象深度监听
  @Watch('checkedKeys', { immediate: true, deep: true })
  onCheckedKeysChanged(newValue: any, oldValue: any) {
    console.log(newValue);
    console.log(oldValue);
  }
  onExpand(expandedKeys:any) {
    console.log('onExpand', expandedKeys);
    this.expandedKeys = expandedKeys;
    this.autoExpandParent = false;  // 设置为false时，子节点展开时父节点也可以折叠
  }
  onCheck(checkedKeys:any) {
    console.log('onCheck', checkedKeys);
    this.checkedKeys = checkedKeys;
  }
  onSelect(selectedKeys:any, info:any) {
    console.log('onSelect', info);
    this.selectedKeys = selectedKeys;
  }
  mounted() { 
  }
  beforeDestroy() {
  }
}